<template>
  <div class="layout-all">
    <control :config="config" />
    <div class="layout-header" style="float:left">
      <router-link to="/group_abt/group/list">
        <el-button
          type="primary"
          style="margin-left:0px"
        >返回</el-button>
      </router-link>
    </div>
    <div class="layout-content">
      <el-table
        :data="tableData"
        stripe
        align="center"
        highlight-current-row
        style="width: 100%;margin-top:50px"
      >
        <el-table-column align="center" prop="title" label="公告标题" />
        <el-table-column align="center" prop="content" label="公告内容" width="250">
          <!-- <template slot-scope="scope">
            <img :src="scope.row.url" width="100%">
          </template> -->
        </el-table-column>
        <el-table-column align="center" prop="create_time" label="创建时间" width="250" />
        <el-table-column align="center" prop="update_time" label="修改时间" width="250" />
        <el-table-column align="center" prop="status" label="是否启用" width="80">
          <template slot-scope="scope">
            <el-button
              :type="scope.row.status === 1 ? 'primary' : 'success'"
              size="mini"
              @click="change_status(scope.row.id,'status' ,scope.row.status)"
            >{{ scope.row.status === 1 ? "是" : "否" }}</el-button>
          </template>
        </el-table-column>
        <el-table-column
          align="center"
          prop="telephone"
          fixed="right"
          width="240"
          size="mini"
          label="操作"
        >
          <template slot-scope="scope">
            <!-- <router-link :to="'/ad_abt/ad/form?id=' + scope.row.id">
              <el-button type="primary" icon="el-icon-edit" />
            </router-link> -->
            <el-button
              size="small"
              type="danger"
              icon="el-icon-delete"
              @click="onDel(scope.row.id)"
            />
          </template>
        </el-table-column>
      </el-table>
    </div>
    <!-- <el-pagination
      :current-page="current_page"
      :page-size="per_page"
      layout="total, prev, pager, next, jumper"
      :total="total"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    /> -->
  </div>
</template>

<script>
import control from '../../components/control/control'
export default {
  components: { control },
  data() {
    return {
      group_id: 0,
      config: [
        { type: 'text', placeholder: '请输入内容', field: 'title', val: '' }
      ],
      value: '',
      searchWhere: {
        title: ''
      },
      tableData: [],
      total: 0,
      current_page: 1,
      per_page: 14
    }
  },
  mounted() {
    if (this.$route.query.id) {
      this.group_id = this.$route.query.id
    }
    this.onSearch()
  },
  methods: {
    // 查询
    handleSizeChange(val) {
      this.onSearch()
    },
    handleCurrentChange(val) {
      this.current_page = val
      this.onSearch()
    },
    onSearch() {
      // const form = {}
      // form.page = this.current_page
      // form.map = this.searchWhere
      this.get('/admin/group/notice_log?group_id=' + this.group_id).then(e => {
        this.tableData = e.list.data
        this.per_page = e.list.per_page
        this.total = e.list.total
        this.current_page = e.list.current_page
      })
    },
    // 添加
    onAdd() {},
    // 编辑
    onEdit(id) {
      console.log(id)
    },
    // 修改状态
    change_status(id, field, val) {
      // this.update(id, val, field, 'group').then(e => {
      //   e ? this.onSearch() : ''
      // })
    },
    // 删除
    onDel(id) {
      // this.$msg_confirm().then(e => {
      //   if (e) {
      //     this.get('/admin/group/del?id=' + id, this.form, 'POST').then(e => {
      //       this.onSearch()
      //     })
      //   }
      // })
    }
  }
}
</script>

<style>
.layout-all {
  margin-top: 20px;
  margin-left: 10px;
}
.layout-content {
  margin-top: 20px;
}
</style>>
